import { AppServiceBase, Http } from "ibiz-core";
import { Environment } from "@/environments/environment";

/**
 * @description 环境工具类
 *
 * @export
 * @class EnvironmentUtil
 */
export class EnvironmentUtil {

    /**
     * @description 初始化应用环境变量
     *
     * @memberof EnvironmentUtil
     */
    public static async initAppEnvironment() {
        const runEnvironment = Environment;
        try {
            const injectEnvironment = await Http.getInstance().get('/api/app/environment');
            if (injectEnvironment && Object.keys.length > 0) {
                Object.assign(runEnvironment, injectEnvironment?.data ? injectEnvironment.data : {});
            } 
        } catch (error) {
            console.error(error);
        }finally{
            AppServiceBase.getInstance().setAppEnvironment(runEnvironment);
        }  
    }

}